In this article, we will cover the creation of accounts and units using the Remote API. These objects are essential when working with Wialon, and their creation requires a chain of mandatory actions.
Creating an Account
Before performing this action, it is necessary to remember two important terms:
- Creator — this is the user of the system on whose behalf this object was created.
- Account — this is a macro-object of the system, which represents the unity of a resource, a user, and a billing plan.
Based on this, to create an account, you need to:
- Find a suitable billing plan.
- Find the system ID of the user-creator which will relate to the future account creator.
- Create a new user on behalf of the found user-creator.
- Create a resource on behalf of the new user.
- Merge the new user, resource, and billing plan into an account.
Let's consider the requests that will be needed at each of these steps, using the following example: it is necessary to create an account with the name sdk_account, which will be located under the account of the user manager in the service hierarchy.
1. Searching a Billing Plan
Use the request core/get_account_data.
https://hst-api.wialon.com/wialon/ajax.html?svc=core/get_account_data¶ms={"type":1}&sid=SESSION_IDENTIFIER
The names of assigned billing plans will be displayed in the response to the request in the subPlans parameter. Let's assume that we will use a billing plan with the name standard_client.
2. Searching the System ID of the User-creator
Use the request core/search_items.
https://hst-api.wialon.com/wialon/ajax.html?svc=core/search_items¶ms={"spec":{"itemsType":"user","propName":"sys_name","propValueMask":"manager","sortType":"sys_name"},"force":1,"flags":1,"from":0,"to":0}&sid=SESSION_IDENTIFIER
Parameter and its value | Description |
---|---|
"itemsType":"user" | The search will be performed on users. |
"propName":"sys_name" | The search will be performed on the name of the item. |
"propValueMask":"manager" | The response will display the user whose name exactly matches the expression manager. |
"sortType":"sys_name" | The sorting will be performed based on the name of the item. |
"force":1 | Previous search results will not be taken into account. |
"flags":1 | The response will only contain information about the general properties. |
"from":0;"to":0 | There will be no restrictions on the number of found items. |
The system ID of the user-creator will be displayed in the response to the request in the id parameter. Let's assume it has a value of 11111.
3. Creating a New User
Use the request core/create_user.
https://hst-api.wialon.com/wialon/ajax.html?svc=core/create_user¶ms={"creatorId":11111,"name":"sdk_account","password":"Pa%24%24w0rd","dataFlags":1}&sid=SESSION_IDENTIFIER
Parameter and its value | Description |
---|---|
"creatorId":11111 | The new user will be created by the user with the system ID 11111. |
"name":"sdk_account" | The new user will have the name sdk_account. |
"password":"Pa%24%24w0rd" | The new user will have the password Pa$$w0rd. |
"dataFlags":1 | Only the general properties of the new user will be displayed in the response. |
The system ID of the new user will be displayed in the response to this request under the id parameter. Let's assume it has a value of 22222.
4. Creating a Resource
Use the request core/create_resource.
https://hst-api.wialon.com/wialon/ajax.html?svc=core/create_resource¶ms={"creatorId":22222,"name":"sdk_account","dataFlags":1,"skipCreatorCheck":0}&sid=SESSION_IDENTIFIER
Parameter and its value | Description |
---|---|
"creatorId":22222 | The new resource will be created by the user with the system ID 22222. |
"name":"sdk_account" | The new resource will have the name sdk_account. |
"dataFlags":1 | Only the general properties of the new resource will be displayed in the response. |
"skipCreatorCheck":0 | Check if the user is currently the creator of any system items. |
The system ID of the new resource will be displayed in the response to this request under the id parameter. Let's assume it has a value of 33333.
5. Account Merging
Use the request account/create_account.
https://hst-api.wialon.com/wialon/ajax.html?svc=account/create_account¶ms={"itemId":33333,"plan":"standard_client"}&sid=SESSION_IDENTIFIER
Parameter and its value | Description |
---|---|
"itemId":33333 | The new account will contain the resource with the system ID 33333. |
"plan":"standard_client" | The new account will use the standard_client billing plan. |
Creating a Unit
To create a unit using the Remote API, you need to:
- Find the system ID of the hardware type.
- Find the system ID of the user-creator, in whose account the future unit will be located.
- Create a unit.
- Assign a unique ID to the unit.
Let's consider the necessary requests using the following example: it is necessary to create a unit Delivery truck with the hardware type Wialon IPS and a unique ID 12345 in the account of the user sdk_account.
1. Searching the System ID of the Hardware Type
Use the request core/get_hw_types.
https://hst-api.wialon.com/wialon/ajax.html?svc=core/get_hw_types¶ms={"filterType":"name","filterValue":["Wialon%20IPS"],"includeType":0,"ignoreRename":1}&sid=SESSION_IDENTIFIER
Parameter and its value | Description |
---|---|
"filterType":"name" | Filtering will be done by the name of the hardware type. |
"filterValue":["Wialon%20IPS"] | The search will be performed by the expression Wialon IPS. |
"includeType":0 | The response will not show any additional information about the hardware type. |
"ignoreRename":1 | Renaming of the hardware types will be ignored in the response. |
The system ID of the hardware type will be displayed in the response to the request in the id parameter. Let's assume it has a value of 44444.
2. Searching the System ID of the User-creator
Use the request core/search_items.
https://hst-api.wialon.com/wialon/ajax.html?svc=core/search_items¶ms={"spec":{"itemsType":"user","propName":"sys_name","propValueMask":"sdk_account","sortType":"sys_name"},"force":1,"flags":1,"from":0,"to":0}&sid=SESSION_IDENTIFIER
Parameter and its value | Description |
---|---|
"itemsType":"user" | The search will be performed on users. |
"propName":"sys_name" | The search will be performed on the name of the item. |
"propValueMask":"sdk_account" | The response will display the user whose name exactly matches the expression sdk_account. |
"sortType":"sys_name" | The sorting will be performed based on the name of the item. |
"force":1 | Previous search results will not be taken into account. |
"flags":1 | The response will only contain information about the general properties. |
"from":0;"to":0 | There will be no restrictions on the number of found items. |
The system ID of the user-creator will be displayed in the response to the request in the id parameter. Let's assume it has a value of 22222.
3. Creating a Unit
Use the request core/create_unit.
https://hst-api.wialon.com/wialon/ajax.html?svc=core/create_unit¶ms={"creatorId":22222,"name":"Delivery%20truck","hwTypeId":"44444","dataFlags":1}&sid=SESSION_IDENTIFIER
Parameter and its value | Description |
---|---|
"creatorId":22222 | The user-creator of the new unit will have the system ID 22222. |
"name":"Delivery%20truck" | The new unit will have the name Delivery truck. |
"hwTypeId":"44444" | The system ID of the hardware type for the new unit will have a value of 44444. |
"dataFlags":1 | Only the general properties of the new unit will be displayed in the response. |
The system ID of the unit will be displayed in the response to the request in the id parameter. Let's assume it has a value of 55555.
4. Assigning a Unique ID
Use the request unit/update_device_type.
https://hst-api.wialon.com/wialon/ajax.html?svc=unit/update_device_type¶ms={"itemId":55555,"deviceTypeId":"44444","uniqueId":"12345"}&sid=SESSION_IDENTIFIER
Parameter and its value | Description |
---|---|
"itemId":55555 | The settings will be changed for the unit with the system ID 55555. |
"deviceTypeId":"44444" | The system ID of the hardware type will have a value of 44444. |
"uniqueId":"12345" | The unique ID of the unit will have a value of 12345. |